using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 得分层
/// 只能有一个实例
/// </summary>
public class CorePrefab : Singleton<CorePrefab>
{
    /// <summary>
    /// 得到物体的位置
    /// </summary>
    public float pos
    {
        get
        {
            return transform.position.y;
        }
    }
    /// <summary>
    /// 得到该物体的高度的一半
    /// </summary>
    /// <returns></returns>
    private float GetHeight()
    {
        if (height == 0)
        {
            Vector3[] v = new Vector3[4];
            transform.GetComponent<RectTransform>().GetWorldCorners(v);
            height = Vector2.Distance(v[0], transform.position) / Mathf.Sqrt(2);
        }
        return height;
    }

    /// <summary>
    /// 图片的高度一半，用于算出时间
    /// </summary>
    [HideInInspector] public float height = 0;

    // Start is called before the first frame update
    void Start()
    {
        print(("core prefab"));
        GetHeight();//计算出高度初始值
        print(height);
    }
}